// 使用 Mock
import Mock from "mockjs";

/**
 * 监听获取加密字符串接口
 */
Mock.mock("/login/getEncryptedString", "get", (res) => {
  return {
    code: 200,
    data: {
      key: "0123456789ABHAEQ",
      iv: "DYgjCEIMVrj2W9xN",
    },
  };
});

/**
 * 监听登录接口
 */
Mock.mock("/login/handleLogin", "post", (res) => {
  const { body } = res;
  const { username, password } = JSON.parse(body);
  if (username != "test" || password != "W/wsYEclum4QgTqIgm7J/g==") {
    return {
      code: 500,
      message: "用户名密码不正确",
    };
  }
  return {
    code: 200,
    data: {
      token: "123456",
      username: username,
      nickname: "测试用户",
    },
    message: "登录成功",
  };
});

/**
 * 监听退出接口
 */
Mock.mock("/login/handleLogout", "post", (res) => {
  return {
    code: 200,
    message: "退出成功",
  };
});

/**
 * 监听获取菜单接口
 */
Mock.mock("/login/getMenuList", "post", (res) => {
  return {
    code: 200,
    message: "获取菜单成功",
    data: [
      {
        id: "1",
        parentid: "0",
        name: "首页",
        icon: "el-icon-s-home",
        url: "/home",
      },
      {
        id: "2",
        parentid: "0",
        name: "设备模块",
        icon: "el-icon-menu",
        children: [
          {
            id: "3",
            parentid: "2",
            name: "设备列表",
            icon: "el-icon-s-grid",
            url: "/dev/list",
          },
          {
            id: "4",
            parentid: "2",
            name: "导出分析",
            icon: "el-icon-share",
            url: "/dev/export",
          },
        ],
      },
      {
        id: "5",
        parentid: "0",
        name: "地图模块",
        icon: "el-icon-menu",
        children: [
          {
            id: "5-1",
            parentid: "5",
            name: "高德地图",
            icon: "el-icon-map-location",
            url: "/map/MapGaoDe",
          },
          {
            id: "5-2",
            parentid: "5",
            name: "百度地图",
            icon: "el-icon-map-location",
            url: "/map/MapBaiDu",
          },
        ],
      },
      {
        id: "7",
        parentid: "0",
        name: "远程遥测",
        icon: "el-icon-thumb",
        url: "/remote/remoteCheck",
      },
    ],
  };
});

/**
 * 监听获取设备列表接口
 */
Mock.mock("/device/queryDevBasicStateList", "post", (res) => {
  return {
    code: 200,
    message: "获取数据成功",
    data: {
      current: 1,
      hitCount: false,
      optimizeCountSql: true,
      orders: [],
      pages: 1,
      records: [
        {
          currentPage: 1,
          deptId: null,
          devId: "272301000169",
          en: "99905704",
          enRegisterState: "已注册",
          gpsTime: "23-03-12 09:28:44",
          latitude: "25.9776",
          lineName: "鹰厦线 鹰潭-厦门",
          locIp: "00000000",
          longitude: "117.3736",
          networkState: "GSMR",
          onlineState: false,
          pageSize: 10,
          tn: "40013",
          tnRegisterState: "未注册",
          updateTime: 1692266171000,
          updateTimeGte: null,
          workingMode: "GSMR",
        },
        {
          currentPage: 1,
          deptId: null,
          devId: "272301000103",
          en: "99905123",
          enRegisterState: "未注册",
          gpsTime: "23-08-18 13:09:52",
          latitude: "25.9776",
          lineName: "张家界醴县",
          locIp: "0.0.0.0",
          longitude: "127.3736",
          networkState: null,
          onlineState: true,
          pageSize: 10,
          tn: "",
          tnRegisterState: "未注册",
          updateTime: 1692335394000,
          updateTimeGte: null,
          workingMode: "未知",
        },
      ],
      searchCount: true,
      size: 10,
      total: 6,
    },
  };
});
